// https://www.luogu.com.cn/problem/UVA572
// 原题地址：https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=513

#include <iostream>
#include <vector>
using namespace std;

int m, n;
char grid[105][105];

int towards[8][2] = {
    {1, 0}, {0, 1}, {-1, 0}, {0, -1},
    {1, 1}, {1, -1}, {-1, -1}, {-1, 1}
};


int dfs(int x, int y) {
    if (x < 0 || x >= m || y < 0 || y >= n || grid[x][y] == '*') {
        return 0;
    }
    grid[x][y] = '*';
    for (int i = 0; i < 8; i++) {
        dfs(x + towards[i][0], y + towards[i][1]);
    }
    return 1;
}


void run() {
    vector<pair<int, int>> oilPlaces;
    // 转换成为岛屿问题了 BFS 更快
    int ans = 0;
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            ans += dfs(i, j);
        }
    }
    printf("%d\n", ans);
}


int main() {
    while (true) {
        scanf("%d %d", &m, &n);
        if (m == 0 && n == 0) {
            break;
        }
        for (int i = 0; i < m; i++) {
            scanf("%s", grid[i]);
        }
        run();
    }

    return 0;
}

/*
*@*@*
*****
*@*@*
*/